# Define here the models for your scraped items
#
# See documentation in:
# https:#docs.scrapy.org/en/latest/topics/items.html

import scrapy


class hs300_stocks(scrapy.Item):
    '''
    1：爬取沪深300指数成分股的股票-hs300_stocks
    https://data.eastmoney.com/other/index/
    '''
    stock_code= scrapy.Field() # 股票代码
    stock_name= scrapy.Field() # 股票简称
    weight = scrapy.Field() # 股票简称
    close_price= scrapy.Field() # 最新价(元)
    related_info= scrapy.Field() # 相关资料
    main_industry= scrapy.Field() # 主营行业
    region= scrapy.Field() # 地区
    earnings_per_share= scrapy.Field() # 每股收益(元)
    net_asset_per_share= scrapy.Field() # 每股净资产(元)
    net_assets= scrapy.Field() # 净资产
    return_rate= scrapy.Field() # 收益率( % )
    total_shares= scrapy.Field() # 总股本(亿股)
    circulation_shares= scrapy.Field() # 流通股本(亿股)
    circulation_market_value= scrapy.Field() # 流通市值(亿元)

class company_core_data_monthly(scrapy.Item):
    stock_code = scrapy.Field()  # 股票代码
    stock_name = scrapy.Field()  # 股票简称
    profit= scrapy.Field() # 收益
    pe_dynamic= scrapy.Field() # PE(动)
    net_asset_per_share= scrapy.Field() # 每股净资产
    market_value_to_net_asset= scrapy.Field() # 市净率
    total_revenue= scrapy.Field() # 总营收
    revenue_growth= scrapy.Field() # 总营收同比
    net_profit= scrapy.Field() # 净利润
    profit_growth= scrapy.Field() # 净利润同比
    gross_margin= scrapy.Field() # 毛利率
    net_profit_margin= scrapy.Field() # 净利率
    return_on_equity= scrapy.Field() # ROE
    liability_ratio= scrapy.Field() # 负债率
    total_shares= scrapy.Field() # 总股本
    market_value= scrapy.Field() # 总值
    circulation_shares= scrapy.Field() # 流通股
    circulation_value= scrapy.Field() # 流值
    undistributed_profit_per_share= scrapy.Field() # 每股未分配利润
    create_date = scrapy.Field()  # 创建时间


class company_transaction_data_daily(scrapy.Item):
    today_open= scrapy.Field() # 今开
    highest= scrapy.Field() # 最高
    turnover= scrapy.Field() # 换手
    trading_volume= scrapy.Field() # 成交量
    market_value_added= scrapy.Field() # 市盈(动)
    total_market_value= scrapy.Field() # 总市值
    yesterday_close= scrapy.Field() # 昨收
    lowest= scrapy.Field() # 最低
    volume_ratio= scrapy.Field() # 量比
    trading_amount= scrapy.Field() # 成交额
    market_value_clean= scrapy.Field() # 市净
    circulation_market_value= scrapy.Field() # 流通市值



class margin_trading_daily(scrapy.Item):
    finance_balance= scrapy.Field() # 融资余额(元)
    finance_balance_ratio= scrapy.Field() # 融资余额占流通市值比(%)
    finance_buy_amount= scrapy.Field() # 买入额(元)
    finance_repay_amount= scrapy.Field() # 偿还额(元)
    finance_net_buy_amount= scrapy.Field() # 净买入(元)
    margin_balance= scrapy.Field() # 融券余额(元)
    margin_stocks= scrapy.Field() # 余量(万股)
    margin_sell_amount= scrapy.Field() # 卖出量(万股)
    margin_repay_amount= scrapy.Field() # 偿还量(万股)
    margin_net_sell_amount= scrapy.Field() # 融券净卖出(万股)
    margin_finance_balance= scrapy.Field() # 融资融券余额(元)
    margin_finance_balance_difference= scrapy.Field() # 融资融券余额差值(元)




class money_flow_daily(scrapy.Item):
    net_amount= scrapy.Field() # 净额
    net_percentage= scrapy.Field() # 净占比
    main_net_inflow= scrapy.Field() # 今日主力净流入
    large_net_inflow= scrapy.Field() # 今日超大单净流入
    big_net_inflow= scrapy.Field() # 今日大单净流入
    medium_net_inflow= scrapy.Field() # 今日中单净流入
    small_net_inflow= scrapy.Field() # 今日小单净流入


class news_daily(scrapy.Item):
    title= scrapy.Field() # 新闻标题
    publish_time= scrapy.Field() # 发布时间
    link= scrapy.Field() # 新闻链接
    notice_title= scrapy.Field() # 公告标题
    notice_type= scrapy.Field() # 公告类型
    notice_date= scrapy.Field() # 公告日期


class block_trade_daily(scrapy.Item):
    price= scrapy.Field() # 成交价
    quantity= scrapy.Field() # 成交数量
    amount= scrapy.Field() # 成交金额
    buyer_name= scrapy.Field() # 买方名称
    seller_name= scrapy.Field() # 卖方名称
    date= scrapy.Field() # 日期
    trade_time= scrapy.Field() # 交易时间
    change_rate= scrapy.Field() # 涨跌幅( % )
    close_price= scrapy.Field() # 收盘价(元)
    deal_price= scrapy.Field() # 成交价(元)
    discount_rate= scrapy.Field() # 折溢率( % )
    volume= scrapy.Field() # 成交量(万股)
    turnover= scrapy.Field() # 成交额(万元)
    turnover_ratio= scrapy.Field() # 成交额 / 流通市值( % )
    buyer_department= scrapy.Field() # 买方营业部
    seller_department= scrapy.Field() # 卖方营业部


class yearly_financial_report(scrapy.Item):
    earnings_per_share= scrapy.Field() # 每股收益(元)
    total_revenue= scrapy.Field() # 营业总收入(元)
    last_year= scrapy.Field() # 去年同期(元)
    growth_rate= scrapy.Field() # 同比增长( % )
    quarterly_growth_rate= scrapy.Field() # 季度环比增长( % )
    net_profit= scrapy.Field() # 净利润(元)
    last_year_net_profit= scrapy.Field() # 去年同期(元)
    profit_growth_rate= scrapy.Field() # 同比增长( % )
    quarterly_profit_growth_rate= scrapy.Field() # 季度环比增长( % )
    net_assets_per_share= scrapy.Field() # 每股净资产(元)
    net_assets_return_rate= scrapy.Field() # 净资产收益率( % )
    announcement_date= scrapy.Field() # 公告日期

class quarterly_financial_report(scrapy.Item):
    basic_eps= scrapy.Field() # 基本每股收益(元)
    deducted_eps= scrapy.Field() # 扣非每股收益(元)
    diluted_eps= scrapy.Field() # 稀释每股收益(元)
    net_assets_per_share= scrapy.Field() # 每股净资产(元)
    per_share_provident_fund= scrapy.Field() # 每股公积金(元)
    per_share_undistributed_profit= scrapy.Field() # 每股未分配利润(元)
    per_share_operating_cash_flow= scrapy.Field() # 每股经营现金流(元)
    growth_ability_indicator= scrapy.Field() # 成长能力指标
    total_revenue= scrapy.Field() # 营业总收入(元)
    gross_profit= scrapy.Field() # 毛利润(元)
    net_profit= scrapy.Field() # 归属净利润(元)
    deducted_net_profit= scrapy.Field() # 扣非净利润(元)
    revenue_growth_rate= scrapy.Field() # 营业总收入同比增长( % )
    net_profit_growth_rate= scrapy.Field() # 归属净利润同比增长( % )
    deducted_net_profit_growth_rate= scrapy.Field() # 扣非净利润同比增长( % )
    revenue_rolling_growth_rate= scrapy.Field() # 营业总收入滚动环比增长( % )
    net_profit_rolling_growth_rate= scrapy.Field() # 归属净利润滚动环比增长( % )
    deducted_net_profit_rolling_growth_rate= scrapy.Field() # 扣非净利润滚动环比增长( % )
    net_assets_return_rate= scrapy.Field() # 净资产收益率(加权)( % )
    net_assets_return_rate_deducted= scrapy.Field() # 净资产收益率(扣非 / 加权)( % )
    total_assets_return_rate= scrapy.Field() # 总资产收益率(加权)( % )
    gross_margin= scrapy.Field() # 毛利率( % )
    net_profit_margin= scrapy.Field() # 净利率( % )
    advances_to_accounts_rate= scrapy.Field() # 预收账款 / 营业总收入
    sales_net_cashflow_rate= scrapy.Field() # 销售净现金流 / 营业总收入
    operating_net_cashflow_rate= scrapy.Field() # 经营净现金流 / 营业总收入
    actual_taxation= scrapy.Field() # 实际税率( % )
    current_ratio= scrapy.Field() # 流动比率
    quick_ratio= scrapy.Field() # 速动比率
    cashflows_ratio= scrapy.Field() # 现金流量比率
    assetliabilities_ratio= scrapy.Field() # 资产负债率( % )
    equity_multiplier= scrapy.Field() # 权益系数
    equity_ratio= scrapy.Field() # 产权比率
    total_asset_turnover_days= scrapy.Field() # 总资产周转天数(天)
    inventory_turnover_days= scrapy.Field() # 存货周转天数(天)
    accounts_receivable_turnover_days= scrapy.Field() # 应收账款周转天数(天)
    total_asset_turnover_times= scrapy.Field() # 总资产周转率(次)
    inventory_turnover_times= scrapy.Field() # 存货周转率(次)
    accounts_receivable_turnover_times= scrapy.Field() # 应收账款周转率(次)

class global_stock_indices(scrapy.Item):
    country_name = scrapy.Field()  # 国家名称
    latest_price = scrapy.Field()  # 最新价
    rising_falling_amounts = scrapy.Field()  # 涨跌额
    percentage_change = scrapy.Field()  # 涨跌幅
    opening_price = scrapy.Field()  # 开盘价
    maximum_price = scrapy.Field()  # 最高价
    bottom_price = scrapy.Field()  # 最低价
    closing_price = scrapy.Field()  # 昨收价
    amplitude = scrapy.Field()  # 振幅

class Macro_Money(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    cpi_time = scrapy.Field()  # 详细时间2024.1--2024.4
    cpi= scrapy.Field()  # 居民消费价格指数
    xzxd_data_time = scrapy.Field()  # 新增信贷数据时间
    xzxd_data = scrapy.Field()  # 新增信贷数据
    pmi_time= scrapy.Field()  # 采购经理人指数时间
    pmi= scrapy.Field()  # 采购经理人指数
    reserve_requirement_ratio_time= scrapy.Field()  # 存款准备金率时间
    reserve_requirement_ratio= scrapy.Field()  # 存款准备金率
    ppi_time = scrapy.Field()  # 工业品出场价格指数时间
    ppi = scrapy.Field()  # 工业品出场价格指数
    money_supply_time= scrapy.Field()  # 货币供应量时间
    money_supply= scrapy.Field()  # 货币供应量
    fiscal_revenue_time= scrapy.Field()  # 财政收入时间
    fiscal_revenue= scrapy.Field()  # 财政收入
    total_social_sales_time= scrapy.Field()  # 社会商品销售总额时间
    total_social_sales= scrapy.Field()  # 社会商品销售总额
    customs_imports_and_exports_time= scrapy.Field()  # 海关进出口一览时间
    customs_imports_and_exports= scrapy.Field()  # 海关进出口一览

class daily_exchange_rate(scrapy.Item):
    code = scrapy.Field()  #代码
    name= scrapy.Field()  #名称
    large_net_inflow= scrapy.Field()  #最新价
    change_amount= scrapy.Field()  #涨跌额
    change_percentage= scrapy.Field()  #涨跌幅
    open_price= scrapy.Field()  #今开
    highest_price= scrapy.Field()  #最高
    lowest_price= scrapy.Field()  #最低
    previous_close_price= scrapy.Field()  #昨收
    create_date = scrapy.Field()  # 创建时间



if __name__=="__main__":
    # 创建对象
    my_object = hs300_stocks()

    # 获取对象的类型名称
    class_name = type(my_object).__name__
    print(class_name)  # 输出: MyClass
    # 获取对象的所有属性和方法名称列表
    attributes_list = my_object.fields.keys()
    print(attributes_list)